package com.cskaoyan.controller.vx.order;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.bo.IdBO;
import com.cskaoyan.bean.bo.vxBo.CartToOrderBO;
import com.cskaoyan.bean.bo.vxBo.VXCommentBO;
import com.cskaoyan.bean.vo.TVO;
import com.cskaoyan.bean.vo.vxVo.OrderDetailGoodsVO;
import com.cskaoyan.bean.vo.vxVo.OrderDetailVO;
import com.cskaoyan.bean.vo.vxVo.OrderListVO;
import com.cskaoyan.bean.vo.vxVo.WXSubmitVO;
import com.cskaoyan.service.vx.order.WXOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author by WANGJun
 * @date 2022/6/7 14:14
 */
@RestController
@RequestMapping("wx/order")
public class WXOrderController {

    @Autowired
    WXOrderService WXOrderService;

    @RequestMapping("comment")
    public BaseRespVo comment(@RequestBody VXCommentBO VXCommentBO) {
        WXOrderService.comment(VXCommentBO);
        return BaseRespVo.ok(null);
    }

    @RequestMapping("list")
    public BaseRespVo list(Short showType, Integer page, Integer limit) {
        TVO<OrderListVO> orderListVOTVO = WXOrderService.list(showType, page, limit);
        return BaseRespVo.ok(orderListVOTVO);
    }

    @RequestMapping("detail")
    public BaseRespVo detail(Integer orderId) {
        OrderDetailVO detailVO = WXOrderService.detail(orderId);
        return BaseRespVo.ok(detailVO);
    }

    @RequestMapping("cancel")
    public BaseRespVo cancel(@RequestBody IdBO idBO) {
        Integer orderId = idBO.getOrderId();
        WXOrderService.cancel(orderId);
        return BaseRespVo.ok(null);
    }

    @RequestMapping("refund")
    public BaseRespVo refund(@RequestBody IdBO idBO) {
        Integer orderId = idBO.getOrderId();
        WXOrderService.refund(orderId);
        return BaseRespVo.ok(null);
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody IdBO idBO) {
        Integer orderId = idBO.getOrderId();
        System.out.println("orderId"+orderId);
        WXOrderService.delete(orderId);
        return BaseRespVo.ok(null);
    }

    @RequestMapping("confirm")
    public BaseRespVo confirm(@RequestBody IdBO idBO) {
        Integer orderId = idBO.getOrderId();
        WXOrderService.confirm(orderId);
        return BaseRespVo.ok(null);
    }

    //待评价商品信息
    @RequestMapping("goods")
    public BaseRespVo goods(Integer orderId, Integer goodsId) {
        // Integer orderId = idBO.getOrderId();
        // Integer goodsId = idBO.getGoodsId();
        OrderDetailGoodsVO goodsVO = WXOrderService.goods(orderId, goodsId);
        return BaseRespVo.ok(goodsVO);
    }

    @RequestMapping("submit")
    public BaseRespVo submit(@RequestBody CartToOrderBO cartToOrderBO) {
        WXSubmitVO wxSubmitVO = WXOrderService.submit(cartToOrderBO);
        return BaseRespVo.ok(wxSubmitVO);
    }

    @RequestMapping("prepay")
    public BaseRespVo prepay(@RequestBody IdBO idBO) {
        Integer orderId = idBO.getOrderId();
        WXOrderService.prepay(orderId);
        return BaseRespVo.ok(null);
    }

}
